interface ItemType {
    id:string,
    img:string,
    title:string
}

interface DataType {
    code:number,
    data:ItemType[]
}


Ajax('/api/getlist',(data:DataType)=>{
    // console.log(data);
    render(data.data)
})

function render(data:ItemType[]){
    //获取渲染位置
    const boxDom:Element | null = document.querySelector(".box");

    (boxDom as Element).innerHTML = data.map(item => {
        return `<div class="item" id="${item.id}">
                    <img src="${item.img}" alt="">
                    <div>
                        <h2>${item.title}</h2>
                    </div>
                </div>
        `
    }).join('')
}